import 'package:device_info/device_info.dart';
import 'package:package_info/package_info.dart';
import 'dart:io';

/// 是否生产环境
const bool inProduction = const bool.fromEnvironment("dart.vm.product");

///查询有关应用程序包的信息。这适用于iOS和Android。
class PlatformUtils {
  static Future<PackageInfo> getAppPackgeInfo() {
    return PackageInfo.fromPlatform();
  }

  ///获取app版本号
  static Future<String> getAppVersion() async {
    PackageInfo packageInfo = await PackageInfo.fromPlatform();

    return packageInfo.version;
  }

  /// 获取特定平台的设备信息, IOS 或是 安卓.
  static Future getDeviceInfo() async {
    DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();

    if (Platform.isAndroid) {
      return await deviceInfo.androidInfo;
    } else if (Platform.isIOS) {
      return await deviceInfo.iosInfo;
    } else {
      return null;
    }
  }
}
